var app = getApp(),
appData = getApp().globalData,
utils = require('../../../utils/utils.js'),
refreshTimes = -1,
Url = 'login/';
Page({
  data: {
    excNum: appData.receive.length,
    caculate: true,  // 已兑换人数是否计算完成
  },

  onLoad: function(pre) {
    refreshTimes = -1;
    if (appData.admin) app.toast('管理员登录成功', 'success');
  },
  onShow: function() {
    this.setData({ share: appData.share });
    if (!++refreshTimes) return 0;
    app.request('login/refresh', { id: appData.user.id }).then((newInfo) => {
      console.log(newInfo.name, newInfo);
      appData.share = newInfo.data.share;
      appData.receive = newInfo.data.receive;
      if (!appData.share.total) appData.share.total = parseFloat("0").toFixed(2)
    })
    this.setData({ share: appData.share });
    // wx.navigateTo({ url: '../../admin/admin/admin' })
    // wx.navigateTo({ url: '../../module/ticket/ticket' })
  },
  allMoney: function() { wx.navigateTo({ url: '../../module/money/money/money' })},
  onShareAppMessage: function() {
    return {
      title: '大家都在抢，酒店免费住！',
      path: '/pages/index/receive/receive?id=' + appData.share.share_id +'&ht='+ appData.hotel,
      imageUrl: appData.Url + 'assets/share/share2.jpg',
      suaccess: function (res) {
        console.log(res);
        wx.showShareMenu({
          withShareTicket: true,
        })
      },
      fail: function(res) {
        console.log(res)
      }
    }
  },
})